-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix RPCtoDTTranslator #25275
Fix RPCtoDTTranslator #25275
Conversation
This avoids a crash seen in production. In addition, moved declaration of additional loop variables to be within the scope of the loop.
The constructor now holds a const& to the collection.
Create a L1MuTMChambPhContainer on the stack rather than having a pointer to null. Also made calling arguments const.
The helper classes were being made each call and where being allocated via a shared_ptr. Putting them on the stack is more efficient. Also tried to avoid some copies of returned values.
Moved the variables to be on the stack. They have the same lifetime as before but can be handled more efficiently.
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-25275/7296 |
please test |
The tests are being triggered in jenkins. |
A new Pull Request was created by @Dr15Jones (Chris Jones) for master. It involves the following packages: L1Trigger/L1TTwinMux @nsmith-, @rekovic, @cmsbuild, @thomreis can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
NOTE: many of the helper classes in this package, e.g. RPCHitCleaner, should just be converted to a function which takes as arguments the values passed to the constructor and return the value accessed from the |
please test workflow 136.855,136.867,136.879,136.891 |
@@ -41,15 +41,15 @@ void DTLowQMatching::Matching(int track_seg){ | |||
|
|||
L1MuDTChambPhDigi * dtts=nullptr; | |||
L1MuDTChambPhDigi * rpcts1=nullptr; | |||
auto m_phiRPCDigis_tm=std::make_shared<L1MuTMChambPhContainer>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shared_ptr only had the lifetime of this function.
@@ -41,16 +41,16 @@ void DTRPCBxCorrection::run( const edm::EventSetup& c) { | |||
|
|||
void DTRPCBxCorrection::BxCorrection(int track_seg){ | |||
|
|||
auto m_phiDTDigis_tm=std::make_shared<L1MuTMChambPhContainer>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The share_ptr only lived as long as the function.
dtts1=nullptr; dtts2=nullptr; | ||
dtts1 = inphiDigis->chPhiSegm1(wheel,station,sector,bx); | ||
dtts2 = inphiDigis->chPhiSegm2(wheel,station,sector,bx - 1 ); | ||
auto dtts1 = inphiDigis->chPhiSegm1(wheel,station,sector,bx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variables are only used within the loop so should be scoped appropriately.
const std::vector<L1MuDTChambPhDigi> * vInCon=inphiDigis->getContainer(); | ||
inphiDigis_tm->setContainer(*vInCon); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would actually have caused address 0 to be written on (since linke 108 the value is set to nullptr) which would cause a segmentation violation.
@@ -47,29 +47,29 @@ edm::Handle<L1MuDTChambThContainer> thetaDigis, edm::Handle<RPCDigiCollection> r | |||
|
|||
|
|||
///Align track segments that are coming in bx-1. | |||
auto alignedDTs=std::make_shared<AlignTrackSegments>(*inphiDigis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shared_ptrs in this routine only have the lifetime of this function.
} | ||
|
||
namespace { | ||
constexpr int max_rpc_bx = 2; | ||
constexpr int min_rpc_bx = -2; | ||
|
||
struct rpc_hit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The struct is only used within the implementation so it is better to encapsulate it here.
int strip; | ||
int roll; | ||
int layer; | ||
rpc_hit(int pbx, int pstation,int psector, int pwheel, RPCDetId pdet, int pstrip, int proll, int player) : bx(pbx),station(pstation),sector(psector),wheel(pwheel), detid(pdet),strip(pstrip),roll(proll),layer(player) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor is needed for the call to emplace_back
.
if(detid.station()==3) vrpc_hit_st3.push_back({digi->bx(), detid.station(), detid.sector(), detid.ring(), detid, digi->strip(), detid.roll(), detid.layer()}); | ||
if(detid.layer()==2) vrpc_hit_layer2.push_back({digi->bx(), detid.station(), detid.sector(), detid.ring(), detid, digi->strip(), detid.roll(), detid.layer()}); | ||
if(detid.station()==4) vrpc_hit_st4.push_back({digi->bx(), detid.station(), detid.sector(), detid.ring(), detid, digi->strip(), detid.roll(), detid.layer()}); | ||
if(detid.layer()==1) vrpc_hit_layer1.emplace_back(digi->bx(), detid.station(), detid.sector(), detid.ring(), detid, digi->strip(), detid.roll(), detid.layer()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace_back
avoids the need to create a temporary and then copy it.
@@ -135,7 +145,7 @@ void RPCtoDTTranslator::run(const edm::EventSetup& c) { | |||
phi1 = phi1 + (radialAngle(vrpc_hit_layer1[l1-1].detid, c, vrpc_hit_layer1[l1-1].strip)); | |||
phi1 /= 2; | |||
} | |||
|
|||
int itr2 = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the one line needed to avoid the crash.
Comparison job queued. |
Comparison is ready Comparison Summary:
|
+1 |
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @davidlange6, @slava77, @smuzaffar, @fabiocos (and backports should be raised in the release meeting by the corresponding L2) |
+1 DQM changes are unrelated to this PR |
Fixed a crash in RPCtoDTTranslator (the first commit)
Also did code improvements to the package, including one case where the orginal code would have lead to a crash.